package com.magiccompass.alipay.barcode.util;

import org.springframework.security.core.context.SecurityContextHolder;

import com.magiccompass.alipay.barcode.security.model.LoginUserModel;

public class UserUtil {
	public static LoginUserModel getCurrentLoginUser(){
		if(SecurityContextHolder.getContext() == null){
			return null;
		}else if(SecurityContextHolder.getContext().getAuthentication() == null){
			return null;
		}else if(SecurityContextHolder.getContext().getAuthentication().getPrincipal() == null){
			return null;
		}else{
			return (LoginUserModel)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		}
	}
}
